package com.copa.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author copa
 * @createDate 2021-01-09 15:15
 * @function 子订单状态
 */

@Getter
@AllArgsConstructor
public enum SubOrderStatusConstant {
    /**
     * 退款状态：
     * 0未退款
     * 1申请退款
     * 2用户退款
     * 3店家退款
     */
    NORMAL(0,"未退款"),
    APPLYREFUND(1,"申请退款"),
    USERREFUND(2,"用户退款"),
    STOREREFUND(3,"店家退款");


    private Integer orderStatus;

    private String statusDesc;


    public static String getDescByValue(short value) {
        for (SubOrderStatusConstant enums : SubOrderStatusConstant.values()) {
            if (enums.getOrderStatus() == value) {
                return enums.getStatusDesc();
            }
        }
        return "";
    }

    public static SubOrderStatusConstant parse(short value){
        for (SubOrderStatusConstant enums : SubOrderStatusConstant.values()) {
            if (enums.getOrderStatus() == value) {
                return enums;
            }
        }
        throw new IllegalArgumentException("无法查找到该类型");
    }

}
